Learn R Programming

phyloseq (version 1.16.2)

sample_names<-: Replace OTU identifier names

Description

Replace OTU identifier names

Usage

sample_names(x) <- value

## S3 method for class 'ANY,ANY': sample_names(x) <- value

## S3 method for class 'ANY,character': sample_names(x) <- value

## S3 method for class 'otu_table,character': sample_names(x) <- value

## S3 method for class 'sample_data,character': sample_names(x) <- value

## S3 method for class 'phyloseq,character': sample_names(x) <- value

Arguments

x
(Required). An object defined by the phyloseq-package that describes OTUs in some way.
value
(Required). A character vector to replace the current sample_names.

Examples

Run this code
data("esophagus")
sample_names(esophagus)
# plot_tree(esophagus, color="sample_names", ladderize="left")
sample_names(esophagus) <- paste("Sa-", sample_names(esophagus), sep="")
sample_names(esophagus)
# plot_tree(esophagus, color="sample_names", ladderize="left") 
## non-characters are first coerced to characters.
sample_names(esophagus) <- 1:nsamples(esophagus)
sample_names(esophagus)
# plot_tree(esophagus, color="sample_names", ladderize="left") 
## Cannot assign non-unique or differently-lengthed name vectors. Error.
# sample_names(esophagus) <- sample(c(TRUE, FALSE), nsamples(esophagus), TRUE)
# sample_names(esophagus) <- sample(sample_names(esophagus), nsamples(esophagus)-1, FALSE)

Run the code above in your browser using DataLab